

//****************变量相关定义**************
//* author:海仔 *
//* Email:rautinee@21cn.com *
//*本程序可自由传播使用，但请务必保留此信息 *
//****************************************

var pagenum=4;
//每页显示几条信息
var page=0;
var contpage;
var BodyText="";
var mode;
var toolBar;
var maxNum;
var column;
var colNum;
var pagesNumber;
var pagesNumber2;

function init(fileName,nodeName){
	mode=nodeName;
	xmlDoc=createXmlDom();
	xmlDoc.async="false";
	xmlDoc.load(fileName)
	//***************这个地方是你根据实际取得的字段名称来改了
	header="<TABLE border=1><tr><td>姓名</td><td>图标</td><td>IP地址</td><td>email</td><td></td><td>日期</td><td></td><td></td></tr>";

	//检索的记录数
	maxNum=xmlDoc.getElementsByTagName(mode).length;
	//每条记录的列数
	column=xmlDoc.getElementsByTagName(mode).item(0).childNodes;
	//每条记录的列数
	colNum=column.length;
	//页数
	pagesNumber=Math.ceil(maxNum/pagenum)-1;

	pagesNumber2=Math.ceil(maxNum/pagenum);
}

//创建XmlDom对象
function createXmlDom(){
	var xmlDoc;
	var BrowserName = window.navigator.BrowserName;
	var version = window.navigator.version;
	if(BrowserName == "Netscape"){
		xmlDoc = document.implementation.createXmlDom("","",null);
	}else if(BrowserName == "Microsoft Internet Explorer"){
		xmlDoc = new window.ActiveXObject("Microsoft.XmalDom");
	}
	return xmlDoc;
}

//
function loadXml(fileName){
	xmlDoc.load(fileName);
}

//上一个页面
function UpPage(page) {
	thePage = "\u524d\u4e00\u9875";
	if (page + 1 > 1) {
		thePage = "<A HREF='#' onclick='Javascript:return UpPageGo()'>\u524d\u4e00\u9875</A>";
	}
	return thePage;
}
function NextPage(page) {
	thePage = "\u540e\u4e00\u9875";
	if (page < pagesNumber) {
		thePage = "<A HREF='#' onclick='Javascript:return NextPageGo()'>\u540e\u4e00\u9875</A>";
	}
	return thePage;
}
function UpPageGo() {
	if (page > 0) {
		page--;
	}
	getContent();
	BodyText = "";
}
//当前的页数
function currentPage() {
	var cp;
	cp = "\u5f53\u524d\u662f\u7b2c " + (page + 1) + " \u9875";
	return cp;
}
//总共的页数
function allPage() {
	var ap;
	ap = "\u603b\u5171 " + (pagesNumber + 1) + " \u9875";
	return ap;
}
function NextPageGo() {
	if (page < pagesNumber) {
		page++;
	}
	getContent();
	BodyText = "";
}

//显示分页状态栏
function pageBar(page) {
	var pb;
	pb = UpPage(page) + " " + NextPage(page) + " " + currentPage() + " " + allPage() + selectPage();
	return pb;
}
function changePage(tpage) {
	page = tpage;
	if (page >= 0) {
		page--;
	}
	if (page < pagesNumber) {
		page++;
	}
	getContent();
	BodyText = "";
}
function selectPage() {
	var sp;
	sp = "<select name='hehe' onChange='javascript:changePage(this.options[this.selectedIndex].value)'>";
	//sp="<select name='hehe' onChange='alert(this.options[this.selectedIndex].value)'>";
	sp = sp + "<option value=''></option>";
	for (t = 0; t <= pagesNumber; t++) {
		sp = sp + "<option value='" + t + "'>" + (t + 1) + "</option>";
	}
	sp = sp + "</select>";
	return sp;
}
function getContent() {
	
	if (!page) {
		page = 0;
	}
	n = page * pagenum;
	endNum = (page + 1) * pagenum;
	if (endNum > maxNum) {
		endNum = maxNum;
	}
	BodyText = header + BodyText;
	for (; n < endNum; n++) {
		BodyText = BodyText + "<div class='art'><div align='center' class='title'><a href='";
		BodyText = BodyText + xmlDoc.getElementsByTagName("htmlUrl").item(n).text;
		BodyText = BodyText + "' target='_blank'><strong>";
		BodyText = BodyText + xmlDoc.getElementsByTagName("title").item(n).text;
		BodyText = BodyText + "</strong></a></div><div class='content'>";
		BodyText = BodyText + xmlDoc.getElementsByTagName("content").item(n).text;
		BodyText = BodyText + "--<a href='"
		BodyText = BodyText + xmlDoc.getElementsByTagName("htmlUrl").item(n).text;
		BodyText = BodyText + " target='_blank'>详细内容</a></div>";
		BodyText = BodyText + "<hr align='left' width='500' /><div class='art-info'>作者：<strong>";
		BodyText = BodyText + xmlDoc.getElementsByTagName("inputUser").item(n).text;
		BodyText = BodyText + "</strong>(阅读：<font color='#FF0000'>";
		BodyText = BodyText + xmlDoc.getElementsByTagName("readTimes").item(n).text;
		BodyText = BodyText + "</font>　发表时间：";
		BodyText = BodyText + xmlDoc.getElementsByTagName("displaytime").item(n).text;
		BodyText = BodyText + "</div></div><hr align='left' width='540' size='1'' noshade='noshade' style='border:1px #cccccc dotted'/>";
		/*for (m = 0; m <= colNum - 1; m++) {
			mName = column.item(m).tagName;
			BodyText = BodyText + ("<TD>" + xmlDoc.getElementsByTagName(mName).item(n).text + "</TD>");
		}*/
		BodyText = BodyText + "</div>";
		mm = "";
	}
	showhtml.innerHTML = BodyText + "</table>" + pageBar(page);
	BodyText = "";
}
function view(fileName,nodeName){
	init(fileName,nodeName);
	getContent();
}

